<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="../css/index.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <style type="text/css">
    body{-webkit-overflow-scrolling:touch;}
    .aui-slide-page-active{background: #fff;width: .8rem;border-radius: 3px;}
    .banner img{}
    img.icon { display: block; margin: .1rem auto; width: 60%; }
    .aui-grid [class*=aui-col-]{padding:0;}
    .aui-grid-label{font-size: .6rem !important;}
    .aui-grid .aui-grid-label{margin-top: 0;}
</style>
</head>
<body class="">
    <div id="html"></div>
<!-- 新手专享 end -->
    <!-- 产品 -->
    <!-- 热卖 -->
    <div class="rm_bar">
        <!-- 热卖列表 -->
         <div class="rm_con">
                <div class="tb_zt_con">
                    <ul class="aui-list aui-media-list" id="list">
                        <!-- <li class="aui-list-item">
                            <div class="aui-media-list-item-inner">
                                <div class="aui-list-item-media">
                                    <img src="../image/banner1.png">
                                </div>
                                <div class="tb_zt_right">
                                    <div class="tb_zt_texttop">
                                        <div class="tb_zt_text">
                                            <div class="tb_zt_texticon"><img src="../image/taobao.png" class="list-tjp-icon"></div>
                                            <div class="tb_zt_texttit aui-ellipsis-1">【爆款返厂】冬春色羊毛圆领冬春色羊毛圆领</div>
                                        </div>
                                        <div class="tb_zt_bq">
                                             <span>预估赚¥8.88</span><span>升级赚¥8.88</span>
                                        </div>
                                    </div>
                                    <div class="tb_zt_textbottom">
                                         <div class="tb_price">¥59<span>¥136</span></div>
                                         <div class="tb_numbar">
                                              <div class="tb_num">346人已买</div>
                                              <div class="tb_yhq quan jb">
                                                  100券
                                                  <div class="dotl"></div>
                                                  <div class="dotr"></div>
                                              </div>
                                         </div>
                                    </div>
                                </div>
                            </div>
                        </li> -->

                     </ul>
               </div>
         </div>
        <!-- 热卖列表end -->
    </div>
    <!-- 热卖 end -->

    <div class="nbsp"></div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js" ></script>
<script type="text/javascript" src="../script/aui-slide.js"></script>
<script type="text/javascript" src="../script/doT.min.js" ></script>
<script type="text/javascript" src="../script/common.js" ></script>
<script type="text/javascript">
    var p=0,id=0;
    apiready = function () {
        api.parseTapmode();

        //下拉刷新
        _Refresh(function(){
            layout();
            getData(id);
        });;

        //流动监听
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:100 //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){
            getData(id);
        });

        //init
        layout();
        getData(id);

    }


    //首页布局
    function layout(){
        //_loading2();
        _Ajax(window.APIServer.IndexLayout,'get','','json',function(ret){
            //_loading2_close();
            //.渲染页面
            if (ret.code) {
                $('#html').html(ret.data.html);
                //setTimeout(slide(),3000);
                slide();
            }else{
                //do nothing
            }

        },'','',true);

    }

    function slide(){
        var slide = new auiSlide({
            container:document.getElementById("aui-slide"),
            // "width":300,
            "height":150,
            "speed":300,
            "pageShow":true,
            "pageStyle":'dot',
            "loop":true,
            'dotPosition':'center',
            "autoPlay": 3000, //自动播放
        })
    }
    //获取淘宝本地商品
    function getData(sid,nav){
        if (nav) {
            p=0;
            id = sid;
            location.href = "#goods";
        }
        p++;
        //$('body').append('<div class="loading-1"><img src="../image/load-1.gif">加载中...</div>');
        _loading2();
        _Ajax(window.APIServer.SectionGoods,'post',{values:{id:sid,p:p}},'json',function(ret){
            _loading2_close();
            //$('.loading-1').remove();
            //.渲染页面
            if (ret.code==1) {//alert(JSON.stringify(ret.data))
                var evalText = doT.template($api.text($api.byId('goodslist')));
                if (nav) {
                    $api.html($api.byId('list'), evalText(ret.data));
                }else{
                    $api.append($api.byId('list'), evalText(ret.data));
                }
               imageCache('.goods_img');
            }else{
                p--;
                $('.loading-1').remove();
                $('body').append('<div class="loading-1">'+ret.msg+'</div>');
            }

        })
    }

</script>
<script id="goodslist" type="text/x-dot-template">
    {{ for (key in it.data){ }}
    <li class="aui-list-item" onclick='open_goods({{= JSON.stringify(it['data'][key]) }})' tapmode>
        <div class="aui-media-list-item-inner">
            <div class="aui-list-item-media">
                <img class="goods_img" src="../image/faleimg.gif" _src="{{= it['data'][key]['pic'] }}">
            </div>
            <div class="tb_zt_right">
                <div class="tb_zt_texttop">
                    <div class="tb_zt_text">
                        <div class="tb_zt_texticon"><img src="../image/{{? it['data'][key]['is_tmall']==0 }}taobao{{?? it['data'][key]['is_tmall']==1 }}tmall{{?? it['data'][key]['is_tmall']==2 }}jd{{?? it['data'][key]['is_tmall']==3 }}pinduoduo{{?}}.png"></div>
                        <div class="tb_zt_texttit aui-ellipsis-1"> {{= it['data'][key]['short_title'] }}</div>
                    </div>
                    <div class="tb_zt_bq">
                         <span>预估赚¥{{= it['data'][key]['earn_yg'] }}</span><span>升级赚¥{{= it['data'][key]['earn_sj'] }}</span>
                    </div>
                </div>
                <div class="tb_zt_textbottom">
                     <div class="tb_price">¥{{= it['data'][key]['price_after_quan'] }}<span>¥{{= it['data'][key]['price'] }}</span></div>
                     <div class="tb_numbar">
                          <div class="tb_num">{{= it['data'][key]['sales'] }}人已买</div>
                          <div class="tb_yhq quan jb">
                              {{= it['data'][key]['quan_price'] }}元券
                              <div class="dotl"></div>
                              <div class="dotr"></div>
                          </div>
                     </div>
                </div>
            </div>
        </div>
    </li>
    {{ } }}
</script>
</html>
